package liurong.driver.zk;

import java.util.Date;
import java.util.List;

import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.ZkClient;

public class ServerMonitor {
	public static void main(String[] args) throws Exception {
		ZkClient zkClient = new ZkClient("127.0.0.1:2181");

		zkClient.subscribeChildChanges(ServerRegister.ROOT_LIURONG, new IZkChildListener() {

			@Override
			public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
				System.out.println(new Date());
				System.out.println("parentPath = " + parentPath);
				System.out.println("currentChilds = " + currentChilds);
			}
		});

		// 保持主进程不退出
		System.in.read();
	}
}
